package com.chen.controller;

import com.chen.common.Result;
import com.chen.pojo.Likes;
import com.chen.service.Impl.LikesServiceImpl;
import com.chen.service.LikesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author chen

 */
@RestController
@Api(value = "LikeController", tags = "点赞")
@RequestMapping("/likes")
public class LikesController {

    @Resource
    private LikesServiceImpl likesService;


    @ApiOperation("判断是插入还是删除")
    @PostMapping("/addLikes")
    public Result addLikes(@RequestBody Likes likes) {
        return likesService.addLikes(likes);
    }


    @ApiOperation("删除")
    @DeleteMapping("/deleteLikes/{foreignId}/{liker}")
    public Result deleteLikes(@PathVariable("foreignId") int foreignId,@PathVariable("liker") String liker) {
        return likesService.deleteLikes(foreignId,liker);
    }


    @ApiOperation("查询")
    @GetMapping("/selectOneikes/{foreignId}/{liker}")
    public Result selectOneikes(@PathVariable("foreignId") int foreignId,@PathVariable("liker") String liker) {
        return likesService.selectLikes(foreignId,liker);
    }

}
